export function showModel(config) {
  return new Promise((resolve, reject) => {
    wx.showModal({
      title: '提示',
      content: config.content,
      success: res => {
        if (res.confirm) {
          resolve(res)
        }
      },
      fail: err => {
        reject(err)
      }
    })
  })
}

export function showToast(config) {
  return new Promise((resolve, reject) => {
    wx.showToast({
      title: config.title,
      icon: config.icon,
      mask: true,
      success: (result)=>{
        resolve(result)
      },
    });
  })
}

export function login() {
  return new Promise((resolve, reject) => {
    wx.login({
      timeout:10000,
      success: (result)=>{
        resolve(result)
      },
      fail: (err)=>{
        reject(err)
      },
    });
  })
}

export function requestPayment(pay) {
  return new Promise((resolve,reject)=>{
    wx.requestPayment({
      ...pay,
      success: (result) => {
       resolve(result)
      },
      fail: (err) => {
        reject(err);
      }
    });     
   })
}